{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = [[1,2,3],[4,5,6],[7,8,9]]\n",
    "Y = [[10,11,12],[13,14,15],[16,17,18]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Initialize a result placeholder\n",
    "result = [[0,0,0], \n",
    "        [0,0,0], \n",
    "        [0,0,0]] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[11, 13, 15], [17, 19, 21], [23, 25, 27]]\n"
     ]
    }
   ],
   "source": [
    "# iterate through rows \n",
    "for i in range(len(X)):    \n",
    "# iterate through columns \n",
    "    for j in range(len(X[0])): \n",
    "        result[i][j] = X[i][j] + Y[i][j] \n",
    "        \n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = [[10,11,12],[13,14,15],[16,17,18]]\n",
    "Y = [[1,2,3],[4,5,6],[7,8,9]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Initialize a result placeholder\n",
    "result = [[0,0,0], \n",
    "        [0,0,0], \n",
    "        [0,0,0]] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[9, 9, 9], [9, 9, 9], [9, 9, 9]]\n"
     ]
    }
   ],
   "source": [
    "# iterate through rows \n",
    "for i in range(len(X)):    \n",
    "# iterate through columns \n",
    "    for j in range(len(X[0])): \n",
    "        result[i][j] = X[i][j] - Y[i][j] \n",
    "        \n",
    "print(result)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
